<?php
// 命令行参数解析
function parseArguments($argv) {
    $options = [];
    $batchSize = 10;
    $limit = null;

    foreach ($argv as $arg) {
        if ($arg === '--proxy-enable') {
            $options['proxy_enable'] = true;
        } elseif (strpos($arg, '--limit=') === 0) {
            $limit = substr($arg, 8);
        } elseif (strpos($arg,'--batch-size=') === 0) {
            $batchSize = substr($arg, 13);
        } elseif ($arg === '--help') {
            echo <<<HELP
Usage: php college-spider.php start [options]

Options:
    --proxy-enable Enable proxy usage (no value needed)
    --limit=      Limit the number of colleges to crawl
    --batch-size= Number of colleges to process per batch (default: 10)
    --help        Show this help message

HELP;
            exit;
        }
    }

    return [
        'options' => $options,
        'batchSize' => $batchSize,
        'limit' => $limit
    ];
}

// 记录脚本开始时间
$startTime = time();

// 返回解析结果
return parseArguments($argv);
